<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Users extends CI_Controller
{
    protected $menu = array(
	'menu_1' => '',
	'menu_2' => '',
	'menu_3' => '',
	'menu_4' => 'active',
    );
    
    function __construct()
    {
	parent::__construct();
	
	if( ! $this->_checkAuth()){
	    redirect('admin/login');
	    exit;
	}
    }
    
    function index()
    {
	$this->mytpl->set_template('admin-bootstrap/menu.html');
	$this->mytpl->clear_cache();
	$this->mytpl->set_var($this->menu);
	$data['menu'] = $this->mytpl->html();
	
	$this->load->model('user_model');
	$this->user_model->set_order_by(array('timer'=>'asc'));
	$var['users'] = $this->user_model->load_records();
	
	$this->mytpl->set_template('admin-bootstrap/users.html');
	$this->mytpl->clear_cache();
	$this->mytpl->set_var($var);
	$data['content'] = $this->mytpl->html();
	
	$this->mytpl->set_template('admin-bootstrap/main.html');
	$this->mytpl->clear_cache();
	$this->mytpl->set_var($data);
	$this->mytpl->display();
    }
    
    /**
    * private function to use in this controller
    */
    function _checkAuth()
    {
	$admin = $this->session->userdata('admin');
	if (isset($admin['user']) && $admin['user'] == 'admin') {
	    return true;
	} else {
	    return false;
	}
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */